from ..utils.db_helper import MySQLHelper

production_conn = None
production_params = {
    "host": "prod-dulz.c98i4cow63lq.us-east-2.rds.amazonaws.com",
    "port": 3306,
    "database": "gentlebands.com_wp_prod",
    "user": "readonly_user",
    "password": "oMpqthnGKxxjyX8HQvUj"
}

def set_production_db_conn():
    global production_conn, production_params
    try:
        production_conn = MySQLHelper(production_params)
    except Exception as e:
        print(f"源数据库链接失败！%s" % str(e) )
    
    return production_conn

def get_production_conn():
    global production_conn
    return production_conn or set_production_db_conn()


mirror_conn = None
mirror_params = {
    "host": "101.37.204.55",
    "port": 3306,
    "database": "mirror",
    "user": "mirror",
    "password": "7r2E2RhJhTaBRrZk"
}


def set_mirror_db_conn():
    global mirror_conn, mirror_params
    try:
        mirror_conn = MySQLHelper(mirror_params)
    except Exception as e:
        print(f"源数据库链接失败！%s" % str(e))

    return mirror_conn


def get_mirror_conn():
    global mirror_conn
    return mirror_conn or set_mirror_db_conn()
